
package com.primeton.eos.oss.model.service;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.eos.system.utility.PageResultList;

import com.eos.data.datacontext.DataContextManager;
import com.eos.data.datacontext.IMUODataContext;

import com.primeton.eos.oss.model.dao.CrecAccountHisDao;
import com.primeton.eos.oss.model.newdataset.CrecAccountHis;

@Service
public class CrecAccountHisService {

    @Autowired
    private CrecAccountHisDao crecAccountHisDao;


    public PageResultList<CrecAccountHis> queryCrecAccountHissWithPage(String password,  int pageSize, int pageIndex) {
        //TODO 记录日志
        return crecAccountHisDao.queryCrecAccountHissWithPage(password,  pageSize, pageIndex);
    }

    public CrecAccountHis getCrecAccountHisById(String id) {
        //TODO 记录日志
        return crecAccountHisDao.getEntity(CrecAccountHis.QNAME, id);
    }

    @Transactional
    public void createCrecAccountHis(CrecAccountHis crecAccountHis) {
        //TODO 记录日志
    	String userName = "";
		IMUODataContext muo = DataContextManager.current().getMUODataContext();
		if (muo != null) {
			userName = muo.getUserObject().getUserName();
		}
        crecAccountHis.set("createUser", userName);
        crecAccountHis.set("createTime", new Date());
        crecAccountHis.set("updateUser", userName);
        crecAccountHis.set("updateTime", new Date());

        crecAccountHisDao.getPrimaryKey(crecAccountHis);
        crecAccountHisDao.insertEntity(crecAccountHis);
    }
    
    @Transactional
    public void modifyCrecAccountHis(CrecAccountHis crecAccountHis) {
        //TODO 记录日志
     	String userName = "";
		IMUODataContext muo = DataContextManager.current().getMUODataContext();
		if (muo != null) {
			userName = muo.getUserObject().getUserName();
		}
        crecAccountHis.set("updateUser", userName);
        crecAccountHis.set("updateTime", new Date());
 
        crecAccountHisDao.updateEntity(crecAccountHis);
    }
    
     @Transactional
    public void removeCrecAccountHis(CrecAccountHis[] crecAccountHis) {
        //TODO 记录日志
        crecAccountHisDao.deleteEntity(crecAccountHis);
    }

}





